/*
 *  Copyright 2011 yura.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package org.opu.db_vdumper.ui;

import java.awt.Image;
import java.net.URL;
import javax.swing.ImageIcon;
import org.opu.db_vdumper.App;
import org.opu.db_vdumper.resources.ResourceHandle;
import org.opu.db_vdumper.ui.component.tabel.models.SelectedComponent;

/**
 *
 * @author Potochnak Yana
 */
public class ViewMethod {

    /**
     *  Return curent view, seted vefore images for bordering
     * @param tv curent view (if it null return null)
     * @return curent view
     */
    public SelectedComponent initView(SelectedComponent tv) {
        if (tv == null){
            return null;
        }

        tv.setSelectBorder(getImg("select.png"));
        tv.setErrorBorder(getImg("error.png"));
        tv.setWarningBorder(getImg("warning.png"));
        tv.setSelectErrorBorder(getImg("selecterror.png"));
        tv.setSelectWarningBorder(getImg("selectwarning.png"));

        return tv;
    }

    /**
     *  Return image by name.<br/>
     * <b>Note:</b> image must be found by {@link #RESOURCE_PATH} URL!
     * @param name image file name <b>(only name)</b>
     * @return image by name
     */
    public Image getImg(String name) {
        return ResourceHandle.getImage(name, ResourceHandle.IconType.small);
    }

}
